package com.example.module_park.ui

import androidx.activity.viewModels
import com.alibaba.android.arouter.facade.annotation.Route
import com.example.lib_common.base.BaseActivity
import com.example.lib_common.base.state.Empty
import com.example.lib_common.base.state.Failed
import com.example.lib_common.base.state.Loading
import com.example.lib_common.base.state.Success
import com.example.lib_common.observeWithLifecycle
import com.example.lib_common.utils.RouterKey
import com.example.lib_common.utils.RouterPath
import com.example.module_park.R
import com.example.module_park.databinding.ActivityEnterpriseDetailBinding
import com.example.module_park.enterprise.EnterpriseViewModel
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
@Route(path = RouterPath.ENTERPRISE_DETAIL_UI)
class EnterpriseDetailActivity : BaseActivity<EnterpriseViewModel,ActivityEnterpriseDetailBinding>() {
    override val mLayoutResId: Int
        get() = R.layout.activity_enterprise_detail
    private  val mViewModel: EnterpriseViewModel by viewModels()


    override fun initView() {
        val enterpriseId = intent.getIntExtra(RouterKey.ENTERPRISE_DETAIL_ID,-1)
        mViewModel.getEnterpriseDetail(enterpriseId)
    }
    override fun initData() {

    }
    override fun initListener() {
        mViewModel.enterpriseDetailState.observeWithLifecycle(this){
            when(it){
                Empty->{

                }
                is Failed->{

                }
                Success->{

                    mBinding.tvCompanyName.text = mViewModel.enterpriseDetail.name
                    mBinding.tvAddress .text = mViewModel.enterpriseDetail.address
                    mBinding.tvContact .text = mViewModel.enterpriseDetail.contactInfo
                    mBinding.tvIndustryType .text = mViewModel.enterpriseDetail.industryType
                    mBinding.tvLegalRepresentative.text = mViewModel.enterpriseDetail.legalRepresentative
                    mBinding.tvIsListed.text = mViewModel.enterpriseDetail.isListedStr()
                    mBinding.tvStatus.text = mViewModel.enterpriseDetail.status
                    mBinding.tvStockCode.text = mViewModel.enterpriseDetail.stockCode
                    mBinding.tvStockName .text = mViewModel.enterpriseDetail.stockName

//                    Glide.with(this).load(mViewModel.enterpriseDetail.photos[0]).into(mBinding.ivCompanyPhoto)
                }
                Loading->{

                }
            }
        }

    }

}